<template>
  <div class="address_edit">
    <van-nav-bar title="添加地址" left-arrow @click-left="$router.back()" />
    <van-address-edit
      :area-list="areaList"
      show-postal
      :address-info ='yInfo'
      show-set-default
      show-search-result
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
    />
  </div>
</template>
 <script>
const list = require("../assets/js/address");
// console.log(province_list);
export default {
  data() {
    return {
      areaList: list,
      yInfo: {}
    };
  },
  created() {
    // console.log(this.$route.query.id);
    let id = this.$route.query.id;
    if (id !== undefined) {
      let data = {
        id: id
      };
      this.$http.get("/address_edits", {params:data}).then(res => {
        console.log(res.data.data[0]);
        this.yInfo = res.data.data[0]
        this.yInfo.areaCode += ''
      });
    }
  },
  methods: {
    onSave(content) {
    //   console.log(content);
      this.$http.post("/address_add", content).then(res => {
        // console.log(res);
        if (res.data.code === 201) {
          this.$router.go(-1);
        }
      });
    },
    onChangeDetail() {}
  }
};
</script>